﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:con="clr-namespace:Q2Q.Controls.Converters"
             xmlns:Converters="clr-namespace:Q2Q.Controls.Converters" x:Class="Controls.NumericalIncrementer" 
             mc:Ignorable="d"
			 x:Name="ThisControl"
             d:DesignHeight="18" Height="18" d:DesignWidth="60">
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="3*" />
			<ColumnDefinition Width="1*" MaxWidth="15" MinWidth="15" />
		</Grid.ColumnDefinitions>
		<TextBox Height="Auto" MinWidth="15" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" Background="{DynamicResource NumericalIncrementer.Static.Background}" Foreground="{DynamicResource TextForeground}" Padding="0,0,4,0" IsUndoEnabled="False" MaxLines="1" FontSize="{Binding FontSize, ElementName=ThisControl}" IsReadOnly="{Binding DisallowTextEntry, ElementName=ThisControl}">
			<TextBox.Resources>
				<con:NumericalIncrementerValueConverter x:Key="NIVC" />
			</TextBox.Resources>
			<TextBox.Text>
				<!--<Binding Path="Value" StringFormat="" ElementName="ThisControl" Mode="TwoWay" />-->
				<MultiBinding Converter="{StaticResource NIVC}" FallbackValue="0.00" Mode="TwoWay">
					<Binding Path="Value" ElementName="ThisControl" />
					<Binding Path="MaxDecimals" ElementName="ThisControl" />
				</MultiBinding>
			</TextBox.Text>
		</TextBox>
		<Grid Grid.Column="1">
			<Grid.RowDefinitions>
				<RowDefinition Height="1*" />
				<RowDefinition Height="1*" />
			</Grid.RowDefinitions>
			<RepeatButton Style="{StaticResource RepeatButton}" Grid.Row="0" x:Name="Incrementer" Click="IncrementValue" Padding="1" Visibility="{Binding IsEnabled, ElementName=ThisControl, Converter={StaticResource BooleanToVisibilityConverter}}">
				<Path x:Name="ArrowTop" Data="M0,4C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4z" Fill="{Binding Foreground, ElementName=Incrementer}" Margin="0" Stretch="Uniform" MaxWidth="18" MaxHeight="15"/>
			</RepeatButton>
			<RepeatButton Style="{StaticResource RepeatButton}" Grid.Row="1" x:Name="Decrementer" Click="DecrementValue" Padding="1" Visibility="{Binding IsEnabled, ElementName=ThisControl, Converter={StaticResource BooleanToVisibilityConverter}}">
				<Path x:Name="ArrowBottom" Data="M0,2.5C0,2.5 0,0.5 0,0.5 0,0.5 3.5,4 3.5,4 3.5,4 7,0.5 7,0.5 7,0.5 7,2.5 7,2.5 7,2.5 3.5,6 3.5,6 3.5,6 0,2.5 0,2.5z" Fill="{Binding Foreground,ElementName=Decrementer}" Margin="0" Stretch="Uniform" MaxWidth="18" MaxHeight="15"/>
			</RepeatButton>
		</Grid>
	</Grid>
</UserControl>